package topic

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'PUT'
        url value(consumer(regex('api/topics/\\d+/visibility')), producer('api/topics/1/visibility'))
        body("""
            {
              "id": 1,
              "programId": 1,
              "title": "title",
              "createTime": "2016-09-09 00:00:00.0",
              "orderNumber": 1,
              "visible": false
            }
        """)
        bodyMatchers {
            jsonPath('$.id',byRegex(number()))
            jsonPath('$.programId',byRegex(number()))
            jsonPath('$.title',byRegex(nonEmpty()))
            jsonPath('$.createTime',byRegex(nonEmpty()))
            jsonPath('$.orderNumber',byRegex(number()))
            jsonPath('$.visible',byRegex(anyBoolean()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status 204
    }
}